package cn.tedu.rtc.controller;

import cn.tedu.rtc.websocket.service.ISendMessageService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangyiping
 * @date 2024/9/20
 */
@RestController
@RequestMapping("/ws")
@Api(tags = "WebSocket 消息发送")
public class MessageSendController {

    @Autowired
    private ISendMessageService messageService;

    @PostMapping("/sendMessage")
    public ResponseEntity<String> testWs() throws InterruptedException {
        for (int i = 0; i < 10; i++) {
            Thread.sleep(1000);
            messageService.sendBatch("888", 1, "test", "Hello!");
        }
        return new ResponseEntity<>("send complete!", HttpStatus.OK);
    }
}
